package http;

import java.io.IOException;
import java.io.OutputStream;

/**
 * @Author: admin
 * @Description:
 * @Date: 2019/3/19 10:28
 */

public class HttpResponse {
    private OutputStream outputStream;


    public HttpResponse(OutputStream outputStream){
        this.outputStream= outputStream;
    }

    public void write(String content) throws IOException {
        StringBuffer httpResponse=new StringBuffer();
        httpResponse.append("Http/1.1 200 OK\n")
                .append("Content-Type: text/html;charset=UTF-8\n")
                .append("\r\n")
                .append("<html><body>")
                .append(content)
                .append("</body></html>");
        outputStream.write(httpResponse.toString().getBytes());
        outputStream.close();
    }

}
